package com.example.demo.Mapper;

import com.example.demo.Entity.PersonalInfo;
import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
@Resource
public interface PersonalInfoMapper {
    @Select("SELECT * FROM personal_info WHERE id = #{id}")
    PersonalInfo findById(Long id);
    @Select(("SELECT * FROM personal_info"))
    List<PersonalInfo> findAll();
    @Update("UPDATE personal_info SET avatar_path =#{avatar_path} WHERE  id=#{id}")
    void updatePath(String avatar_path, Long id);

    @Update("UPDATE personal_info SET " +
            "name = #{name}, " +
            "position_applied = #{position_applied}, " +  // 注意命名风格
            "gender = #{gender}, " +
            "address = #{address}, " +
            "birth_date = #{birth_date}, " +  // 注意命名风格
            "phone = #{phone}, " +
            "email = #{email}, " +
            "avatar_path = #{avatar_path} " +  // 注意命名风格
            "WHERE id = #{id}")
    void update( PersonalInfo user);


    @Insert("INSERT INTO personal_info (name, position_applied, gender,address, birth_date, phone, email, avatar_path) VALUES (#{name},#{position_applied},#{gender},#{address},#{birth_date},#{phone},#{email},#{avatar_path})")
    void insert(PersonalInfo personalInfo);
    @Delete("DELETE * FROM personal_info WHERE id =#{id}")
    void delete(Long id);
}

